package com.qf.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.admin.entity.dto.GoodsColor;
import com.qf.admin.mapper.GoodsColorMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GoodsColorService extends ServiceImpl<GoodsColorMapper , GoodsColor> {

    @Transactional
    public void removeByGoodsId(Long goodsId) {
        QueryWrapper<GoodsColor> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(GoodsColor::getGoodsId, goodsId);
        this.remove(wrapper);
    }

    @Transactional(readOnly = true)
    public List<GoodsColor> getByGoodsId(Long goodsId) {
        QueryWrapper<GoodsColor> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(GoodsColor::getGoodsId , goodsId);
        return this.list(wrapper);
    }
}
